using System;
using System.Collections.Generic;

namespace LannyPractiseCode.Shu
{
    //创建结点类
    //为了让HuffmanNode对象持续排序Collections集合排序
    //让Node实现IComparable接口
    public class HuffmanNode : IComparable<HuffmanNode>
    {
        public int Value { set; get; }
        public HuffmanNode Left;
        public HuffmanNode Right;
        public HuffmanNode(int value)
        {
            this.Value = value;
        }
        public override string ToString()
        {
            return "Node [value={" + Value + "]";
        }
        public int CompareTo(HuffmanNode obj)
        {
            return this.Value - obj.Value;
        }
        //前序遍历
        public void PreOrder()
        {
            System.Console.WriteLine(this);
            if(this.Left!=null)
                this.Left.PreOrder();
            if(this.Right!=null)
                this.Right.PreOrder();
        }
    }
}